package _05数据流;

import java.io.*;

public class DataInputOutputStreamDemo {

	public static void main(String[] args) throws IOException {

//		testWrite();

		testRead();

	}

	private static void testRead() throws IOException {
		
		
		// 1. 打开流
		DataInputStream in = new DataInputStream(new FileInputStream("e:/1.data"));
		
		// 2. 读取
		System.out.println(in.readBoolean());
		System.out.println(in.readInt());
		System.out.println(in.readFloat());
		System.out.println(in.readDouble());
		System.out.println(in.readUTF());
		
		
		// 3. 关闭
		in.close();
		

	}

	private static void testWrite() throws IOException {
		// TODO Auto-generated method stub
		// 1. 打开流
		DataOutputStream out = new DataOutputStream(new FileOutputStream("e:/1.data"));

		// 2. 写入数据
		out.writeBoolean(true); // 1/4
		out.writeInt(4);// 4
		out.writeFloat(3.14F);// 4
		out.writeDouble(3.14);// 8
		out.writeUTF("你好");// 6

		// 3. 关闭文件
		out.close();
	}

}